package com.jtech.dribbble.presenter;

import com.jtech.dribbble.contract.TestContract;
import com.jtech.dribbble.model.bean.TestEntity;
import com.jtech.dribbble.net.ErrorResponse;
import com.jtech.dribbble.net.api.API;
import com.jtech.dribbble.net.call.JCallback;
import com.jtech.dribbble.util.RequestManager;

/**
 * 演示用逻辑处理实现类
 * Created by wuxubaiyang on 16/4/16.
 */
public class TestPresenter implements TestContract.Presenter {
    private TestContract.View view;
    private RequestManager requestManager;

    public TestPresenter(TestContract.View view, RequestManager requestManager) {
        this.view = view;
        this.requestManager = requestManager;
        //让视图绑定逻辑处理类
        view.setPresenter(this);
    }

    @Override
    public void start() {
        //开始请求数据
        requestManager.addCall(API.TestApi().test("").enqueue(new JCallback<TestEntity>() {
            @Override
            public void success(TestEntity response) {
                //请求成功
            }

            @Override
            public void failure(ErrorResponse error) {
                //请求失败
            }
        }));
    }

    @Override
    public void cancel() {

    }
}